Method of detecting memory leak causing portion and execution program thereof

ABSTRACT

To reduce labor required in investigating on a source of memory leaks with regard to the memory leaks generated in executing a program using a language which does not explicitly indicate release of data region. With regard to a plurality of data stored in a memory, relationship of data is grasped twice after an time interval therebetween. Next, increased data C 1,  E 2,  E 3  which are not present in data of a first time are extracted from data of a second time, and weights “1”, “2”, “2” in accordance with data sizes are attached to the increased data. Next, the weights are successively propagated from a lower order data of a destination of reference to a higher order data of a source of reference successively. At this occasion, when there are a plurality of lower order data E 2,  E 3  for a higher order D 0,  a weight constituted by adding the weights “2”, “2” of the plurality of lower data E 2,  E 3  is made to be a weight “4” of the higher order data D 0,  and the weights of the respective data represent leak scores which causes memory leak.

CLAIM OF PRIORITY

The present application claims priority form Japanese applicationP2004-116581 filed on Apr. 12, 2004, the content of which is herebyincorporated by reference into this application.

BACKGROUND OF THE INVENTION

The present invention relates to a method of detecting a memory leakcausing portion generated in executing a program described in aprogramming language of Java language or the like capable of tracking adata relationship with regard to a plurality of data stored in a memoryof a computer and an execution program thereof.

As one of causes by which a computer program does not achieve aperformance as expected, there is pointed out a phenomenon referred toas memory leak in which a data memory region used in the programcontinues to increase. Normally, data generated in executing a programis arranged at a memory region referred to as a heap region. The heapregion is a kind of a memory region used in executing a program and isutilized for storing data a size of a storage region of which isdynamically determined such as data inputted to the program. In storingdata, it is necessary to secure a storing region based on a size of datato be stored and when the data becomes unnecessary, an operation ofreleasing the ensured storage region is needed. When the operation ofreleasing the ensured region is not executed properly or when data ofunfreed area become invisible from the executing system, there isgenerated a state in which the memory region used by the programcontinues to increase, that is, the memory leak.

Patterns of generating the memory leak can be classified broadly intotwo kinds. One is a memory leak happens in a language which explicitlyexecutes an operation of releasing the region as in C language or C++language and another is a memory leak happens in a language whichimplicitly releases the region as in Java language (Java is a trademarkor a registered trademark of Sun Microsystems, Inc. in USA and othercountries).

In a case of a language explicitly instructing release of region in theheap region as in C language or C++ language, a memory leak may occurdue to a deficiency in release of region. Further, there may also occura memory leak by disappearance of a reference to the data storage regionensured in the heap region when other reference is assigned erroneouslyto a field in the heap region holding the reference to the data storageregion before release of the region. As a method of resolving the memoryleak, there is a technology of monitoring allocation and release of adata region in executing a program, regarding a region which is notreleased as data causing memory leak and specifying a portion of memoryleak as described in RATIONAL Software, “Purify: Fast Detection ofMemory Leaks and Access Errors”, Purify Product Information WhitePapers. (hereinafter, referred to as Non-patent Document 1) and atechnology for preventing memory leak by static pointer analysis incompiling as described in David L. Heine and Monica S. Lam, “A PracticalFlow-Sensitive and Context Sensitive C and C++ Memory Leak Detector”,Proc. of the ACM SIGPLAN 2003 conference on Programming language designand implementation, 2003 (hereinafter, referred to as Non-patentDocument 2).

On the other hand, in the case of a programming language for implicitlyexecuting data region release as in Java language, a garbage collectionfunction of recovering an unnecessary data storing region can frequentlybe utilized. A program by Java language is temporarily converted into aprogram by an intermediate language and the program by the intermediatelanguage is executed on a virtual machine. According to the program byJava language, release of the memory region is not designated butunnecessary data is collected by the garbage collection functionprovided to the virtual machine. The above-described implicit release ofthe data region means that, release of the memory region is notdesignated in the program per se by Java language but the region of datais released by the garbage collection function and the like. The garbagecollection function is a function of collecting data deviated from thedata reference relationship and therefore, when there is generated areference for unnecessary data which is not anticipated by a programmerdue to a failure in programming, data does not become an object ofcollecting by the garbage collection function and this causes a memoryleak by which the necessary data continues to increase in the memory.That is, according to the garbage collection function, even in the caseof data which is not needed for a user, the data having the datareference relationship does not become the object of data recovery.

As described above, in the case of a programming language as Javalanguage, the operation of releasing the data region is not explicit andtherefore, it is extremely difficult to specify the leak causing portionin the program, and the method of detecting a memory leak causingportion used for C language or C++ language cannot be used. Therefore,when memory leak is suspected with regard to a program by Java language,there have been developed a technology of indicating a data group whosean amount of memory usage is increased in the memory as described in,for example, U.S. Pat. No. 6,167,535 (hereinafter, referred as PatentDocument 1), or U.S. Pat. No. 6,370,684 (hereinafter, referred to asPatent Document 2), a method of assisting to discover a portion ofgenerating memory leak by illustrating a reference relationship withregard to a certain data selected from a data group as described in WimDe Pauw and Gary Sevitsky, “Visualizing Reference Patterns for SolvingMemory Leaks in Java”, Proc. of the 13th European Conference onObject-Oriented Programming, 1999 (hereinafter, referred to as NonpatentDocument 3).

With regard to memory leak generated in executing a program using alanguage which executes release of the data region implicitly, such asJava language, according to the background arts, only the data groupwhose amount of memory usage is increased in the memory as in PatentDocuments 1, 2, mentioned above, or a reference relationship with regardto a certain data selected from the data group is illustrated as inNonpatent Document 2, mentioned above, and further, in many cases, datain which memory leak is suspected is not frequently single, further,there are an enormous number of the reference relationship of data andtherefore, there poses a problem that an investigation on a source ofproducing memory leak becomes a very difficult operation.

SUMMARY OF THE INVENTION

In view of the above-described problem of the related art, the object ofthe present invention is to provide a method of detecting a memory leakcausing portion capable of reducing labor required for investigating asource of memory leak with regard to memory leak caused by executing aprogram using a language which does not explicitly indicate release of adata region, and an execution program thereof.

A first aspect of the invention with regard to a method of detecting amemory leak causing portion in order to achieve the above-describedobject is a method of detecting a memory leak causing portion generatedin executing a program described in a programming language capable oftracking a reference relationship among data with regard to a pluralityof data stored in a memory of a computer, the method comprising:

a first relationship grasping step of grasping the referencerelationship among data with regard to a plurality of data stored in thememory;

a second relationship grasping step of grasping the referencerelationship among data with regard to the plurality of data stored inthe memory after the first relationship grasping step;

an increased data extracting step of extracting one or more pieces ofincreased data which are not present in the plurality of data whosereference relationship is grasped in the first relationship graspingstep from among the plurality of data whose reference relationship isgrasped at the second relationship grasping step, ; and

a weighting step of attaching weights to each one or more pieces of theincreased data extracted at the increased data extracting step inaccordance with data size of each of the increased data, successivelypropagating the weights from lower order data of a destination ofreference to higher order data of a source of reference successively,and in a propagation process of the weights, when one higher order dataconstitutes the reference relationship with a plurality of lower orderdata, adding the weights of the plurality of lower order data toconstitute the weight of the one higher order data and making theweights of the respective data as leak scores indicating a possibilityof causing the memory leak.

According to the second aspect of the invention with respect to themethod of detecting a memory leak causing portion, in the weighting stepof the first aspect of the invention, one or more pieces of theincreased data are classified for respective data kinds and the weightsin accordance with data sizes of respective data groups are attached tothe classified data groups.

According to the third aspect of the invention with respect to themethod of detecting a memory leak causing portion, the first or thesecond invention further comprises:

a highest leak score data extracting step of extracting a lower orderdata as a data having a high possibility of causing a memory leak when aplurality of data having a highest weight are present in respectiveweights of the plurality of data constituting the reference relationshipand the plurality of data having the highest weight constitutes arelationship between the higher order data and the lower data.

According to the fourth aspect of the invention with respect to themethod of detecting a memory leak causing portion, any one of the firstto the third aspects of the invention further comprises:

a memory leak detecting step of investigating an amount of using thememory by a plurality of times and determining whether the memory leakis generated based on a result of the investigation of the plurality oftimes;

wherein the second relationship grasping step is executed in parallelwith the time when it is determined that the memory leak is generated inthe memory leak detecting step or thereafter.

According to a fifth aspect of the invention with respect to the methodof detecting a memory leak causing portion, any one of the first to thefourth aspects of the invention further comprises:

a program cause portion extracting step of extracting a portiondescribed with a data having a high possibility of causing the memoryleak from the program.

According to a first aspect of the invention with respect to a programfor detecting a memory leak causing portion in order to achieve theabove-described object, there is provided a program for detecting amemory leak causing portion generated in executing a program describedin a programming language capable of tracking a reference relationshipamong data with regard to a plurality of data stored in a memory of acomputer, the program causes the computer to execute:

a first relationship grasping step of grasping the referencerelationship among the data with regard to a plurality of data stored inthe memory;

a second relationship grasping step of grasping the referencerelationship among data with regard to the plurality of data stored inthe memory after the first relationship grasping step;

an increased data extracting step of extracting one or more pieces ofincreased data which are not present in the plurality of data whosereference relationship is grasped in the first relationship graspingstep from among the plurality of data whose reference relationship isgrasped at the second relationship grasping step; and

a weighting step of attaching weights to each of one or more pieces ofthe increased data extracted at the increased data extracting step inaccordance with data sizes of each increased data, successivelypropagating the weights from lower order data of a destination ofreference to higher order data of a source of reference successively,and in a propagation step of the weights, when one higher order dataconstitutes the reference relationship with a plurality of lower orderdata, adding the weights of the plurality of lower order data toconstitute the weight of the one higher order data and making theweights of the respective data leak scores indicating a possibility ofcausing the memory leak.

According to a second aspect of the invention with respect to theprogram of detecting a memory leak causing portion, in the first aspectof the invention, the program causes the computer to execute:

a highest leak score data extracting step of extracting a lower orderdata as a data having a high possibility of causing a memory leak when aplurality of data having a highest weight are present in respectiveweights of the plurality of data constituting the reference relationshipand a plurality of data having the highest weight constitutes arelationship between the higher order data and the lower data.

According to a third aspect of the invention with respect to the programof detecting a memory leak causing portion, in the first or the secondaspect of the invention, the program causes the computer to execute:

a memory leak detecting step of investigating an amount of using thememory by a plurality of times and determining whether the memory leakis generated based on a result of the investigation of the plurality oftimes;

wherein the second relationship grasping step is executed in parallelwith the time when it is determined that the memory leak is generated inthe memory leak detecting step or thereafter.

According to a fourth aspect of the invention with respect to theprogram of detecting a memory leak causing portion, in any one of thefirst to the third aspects of the invention, the program causes thecomputer to execute:

a program cause portion extracting step of extracting a portion of aprogram where data having the high leak score is described from theprogram.

According to a fifth aspect of the invention with respect to the programof detecting a memory leak causing portion, in any of the first to thefourth aspects of the invention, the program causes the computer toexecute:

a displaying step of displaying at least a result of the weighting step.

According to a sixth aspect of the invention with respect to the programof detecting a memory leak causing portion, in the fifth aspect of theinvention, in the displaying step, a plurality of data grasped at thesecond relationship grasping step are displayed in a manner that thereference relationship is seen and the leak scores of the plurality ofdata are respectively displayed.

According to a seventh aspect of the invention with respect to theprogram of detecting a memory leak causing portion, in the fourth aspectof the invention, the program causes the computer to execute:

a displaying step of displaying a name of the data having the highestleak score, a declaration of a kind of the data, and a portion ofdescribing the data in the program described in the programminglanguage.

According to the invention, the weights are attached to the plurality ofdata constituting the reference relationship, the weights are made toconstitute leak scores indicating a possibility of causing the memoryleak and therefore, data being the source of causing the memory leak iseasy to specify and labor required for investigating on the source ofmemory leak can be reduced.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is an explanatory view showing a configuration of a computer inan embodiment according to the invention;

FIG. 2 is a flowchart showing an operation of a memory leak detectionportion in an embodiment according to the invention;

FIG. 3 is an explanatory diagram showing a change in a memory usingamount along with an elapse of time;

FIG. 4 is a flowchart showing an operation of a leak score calculatingportion in an embodiment according to the invention;

FIG. 5 is an explanatory view showing a data storing state in a datamemory in an embodiment according to the invention;

FIGS. 6A and 6B are explanatory views showing a reference relationshipgrasped at a reference relationship grasping step in an embodimentaccording to the invention, FIG. 6A shows a reference relationshipgrasped at the first reference relationship grasping step—and FIG. 6Bshows a reference relationship grasped at the second referencerelationship grasping step—;

FIG. 7 is a detailed flowchart of S23 in the flowchart of FIG. 4;

FIG. 8 is an explanatory view showing extraction of increased data andsequencing thereof in an embodiment according to the invention;

FIG. 9 is an explanatory view showing an example of a weight of eachincreased data in an embodiment according to the invention;

FIG. 10 is a detailed flowchart of S24 in the flowchart of FIG. 4;

FIG. 11 is an explanatory view (part 1) for explaining weightingrespective data having a data relationship in an embodiment according tothe invention;

FIG. 12 is an explanatory view (part 2) for explaining weightingrespective data having a data relationship in an embodiment according tothe invention;

FIG. 13 is a flowchart showing an operation of a program cause portionextracting portion in an embodiment according to the invention; and

FIG. 14 is an explanatory view showing an information display example inan embodiment according to the invention.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

An embodiment of a method of detecting a memory leak causing portionaccording to the present invention will be now explained in thefollowings in reference to the drawings.

FIG. 1 is a view showing a configuration of a computer 100 executing amethod of detecting a memory leak causing portion according to theembodiment.

The computer 100 is a server connected to a network 1. The server 100 isprovided with a processor 110 for executing various processings, aprogram memory 130 stored with various programs 131, 135 executed by theprocessor 110, a data memory 140 stored with various data, an externalstorage device 120, a display device 150, an interface 160 forcommunicating with other device via the network 1.

The external storage device 120 is stored with a program 121 forexecuting a Web service provided by the server 100. The program 121 isdescribed in Java language.

The program memory 130 is stored with a program 131 in which the program121 in Java language stored in the external storage device 120 isconverted into an intermediate language, and the program 135 fordetecting a memory leak causing portion produced by executing theprogram 131.

The processor 110 functionally includes a compiler 112 which convertsthe program 121 stored in the external storage device 120 from Javalanguage to the intermediate language, a virtual machine 111 whichexecutes the program 131 described in the intermediate language, and aleak cause portion detecting portion 115 which functions by executingthe program 135 for detecting a memory leak causing portion. Further,both of the compiler 112 and the virtual machine 111 function byexecuting a program (not illustrated) stored in the program memory 130.The virtual machine 111 is provided with the garbage collection functiondescribed in the background art. Unnecessary data is collected from thedata memory 140 by the garbage collection function. The leak causeportion detecting portion 115 includes a memory leak detecting portion116 which detects memory leak by monitoring a memory using amount of thedata memory 140, a leak score calculating portion 117 which calculatesleak score of a plurality of data stored in a heap region in the datamemory 140, a program cause portion extracting portion 118 whichextracts a portion of the programs described with data having high leakscore from the inspection object programs 121, 131, and a displayportion 119 for making the display device 150 display results of theabove-described respective portions.

Further, although there are the program memory 130 stored with programsand the data memory 140 stored with data according to the embodiment, itis sufficient in the present invention that both a program region and adata region maybe present in a memory and it is not necessary thatmemories are present in the respective regions. Further, although inthis case, the inspection object programs 121, 131 and the leak causeportion detecting program 135 are executed in the single computer 100,the respective programs may be executed by computers different from eachother.

Next, operation of the memory leak detecting portion 116 will beexplained in accordance with a flowchart shown in FIG. 2.

The memory leak detecting portion 116 executes an investigation on ausing amount of the data memory 140 by n times (S11, S12), anddetermines whether memory leak is generated in the data memory 140 froma result of the investigation of n times (S13). When it is determinedthat memory leak is not generated, the processing is finished, and whenit is determined that memory leak is generated, it is notified to theleak score calculating portion 117 (S14) and the processing is finished.

Various methods are conceivable as a method of determining whethermemory leak is generated in the data memory 140 from the result of theinvestigation of n times. For example, it may be determined that memoryleak is generated when a difference Sa between an average value AVE0 ofthe using amounts in the initial m times of the investigation and anaverage value AVE1 of the using amounts in the investigation of later mtimes is larger than a predetermined value as shown by FIG. 3. Further,the ordinate in the drawing designates the memory using amount and theabscissa designates investigation time.

Further, it may be determined that memory leak is generated when adifference Sb between an initial maximum value T0 and a final minimumvalue Bn in the investigation of n times is larger than a previouslydetermined value.

Next, operation of the leak score calculating portion 117 will beexplained in accordance with a flowchart shown in FIG. 4.

First, the leak score calculating portion 117 grasps a data relationshipwith regard to all of data stored in the heap region of the data memory140 (S21). Successively, thereafter, again, the data relationship isgrasped with regard to all the data stored in the heap region of thedata memory 140 (S22). By executing the inspection object program 135,as shown by FIG. 5, each data 141 stored to the heap region of the datamemory 140 includes a payload field 142 constituting a main body of thedata and a reference relationship field 143 indicating a front addressof successive data and the leak score calculating portion 117 grasps thedata relationship from the front address of the successive data storedin the reference relationship field.

Here, assume that at the step of grasping the reference relationship ofa first time (S21), for example, as shown in FIG. 6A, it is grasped thata data A0 refers to data B0, B1, data B1 refers to data C0, data B0refers to data D0, and the data D0 refers to data E0, E1. Further, inthe drawing, a circle designates data and a note on a right lower sideof the circle designates a data size. Further, data indicated by thesame alphabet indicates the same kind of data, that is, the data belongsto the same class in Java language. For example, data E0, E1 indicatedata of the same E kind. Further, at the step of grasping the referencerelationship of a second time (S22), as shown in FIG. 6B, assume that itis grasped that data B1 grasped at the first grasping step of thereference relationship (S21) newly refers to data C1 and data D0 newlyrefers to data E2, E3.

Meanwhile, the first grasping step of the reference relationship (S21)is executed in accordance with a timing of executing the step ofinvesting the memory using amount (S11) shown in FIG. 2 at an initialtime. Further, the step of grasping the reference relationship of thesecond time (S22) is executed after having been informed that memoryleak is generated by executing the step of informing to the leak scorecalculating portion shown in FIG. 2. Further, although here, the step ofgrasping the reference relationship of the second time (S22) afterhaving been informed that memory leak is generated, at each time of thesteps of investigating the memory using amount of n times shown in FIG.2, the reference relationship grasping step may be executed, thereference relationship grasping step of the first time may beconstituted by the reference relationship grasping step of the initialtime, and the reference relationship grasping step of the second timemay be constituted by a reference relationship grasping step wheninformed that memory leak is generated. Further, although here, memoryleak is detected by the memory leak detecting portion 116, the referencerelationship grasping step of the second time (S22) may be executedafter a previously determined period of time after the referencerelationship grasping step of the first time (S21), without executingdetection of leak. As a previously determined time period, when theinspection object program is a program for providing a Web service whichis continuously executed for an extremely long period of time as in theembodiment, a time period of, for example, three days, or one week orthe like is conceivable.

When the reference relationship grasping step of the second time (S22)has been finished, the leak score calculating portion 117 extracts newlyincreased data from a plurality of data constituting the referencerelationship grasped at the reference relationship grasping step of thefirst time (S21) from a plurality of data constituting the referencerelationship grasped at the reference relationship grasping step of thesecond time (S22) and attaches a weight to the increased data (S23).

Here, an explanation will be given of a procedure of extracting thenewly increased data and attaching the weight thereto (S23) inaccordance with a flowchart shown in FIG. 7.

First, the leak score calculating portion 117 scans a plurality of datawhose reference relationship was grasped at the above-describedreference relationship grasping step of the first time (S21) (S31) andsuccessively scans the plurality of data whose reference relationshipwas grasped at the above-described reference relationship grasping stepof the second time (S22) (S32). In scanning the data whose referencerelationship was grasped at the reference relationship grasping step ofthe second time, first, one piece of data (datum?) is selected from theplurality of data whose reference relationship was grasped at thereference relationship grasping step of the second time (S41), and it isdetermined whether the data is the same as one of the plurality of datawhose the reference relationship was grasped at the referencerelationship grasping step of the first time, that is, whether the datais new data (S42). When the data is not new data, the operation returnsagain to step 41, and when the data is new data, the operation acquiresa kind of the data (S43). Here, a kind of data is an aggregation of datahaving a constant relationship among data and corresponds to a class towhich the data belong in Java language as described above. Further, adata size is summed up for each data kind (S44), it is determinedwhether there is data which is not scanned yet (S45), and when there isthe data which is not scanned, the operation returns to S41 and whenthere is not data which is not scanned, the operation is finished.

When scanning of data whose reference relationship was grasped at thereference relationship grasping step of the second time (S32) has beenfinished, as shown by FIG. 8, data C1 and data E2, E3 are extracted asnewly increased data, and the data are classified into an aggregation ofa data C kind and an aggregation of a data E kind and summed-up datasizes of the respective data kinds are acquired. Specifically, data C1is aggregated as the data C kind and data E2, E3 are aggregated as thedata E kind. Further, as the summed-up data size of the data C kind, “2”is acquired and as the summed-up data size of the data E kind, “10(=5+5)” is acquired. Further, in the drawing, a numerical value attachedon a left lower side of each data indicates a data size.

The leak score calculating portion 117 successively sequences respectivedata kinds in an order of increased data kinds having smaller data sizes(S33). Here, as shown by FIG. 8, the data kind C having the smallersummed-up data size in the increased data kinds C, E becomes at a firstorder and the data kind E becomes at a second order.

Next, the leak score calculating portion 117 attaches weights to each ofthe increased data kinds C, E in accordance with orders thereof (S34) tothereby finish the step of extracting the increased data and attachingthe weight to the respective increased data (S23). With regard to theweights attached to respective increased data kinds, specifically, asshown by weight example 1 in FIG. 9, the orders attached at S33 areattached as the weights as they are. Further, although the weights maybe constituted by the orders as they are in this way, the weights may beconstituted by data size ratios as in weight example 2 of FIG. 9. Thatis, in accordance with a data size, data having a large data size may beattached with a large weight and data having a small data size may beattached with a small weight. Further, although here, data is classifiedinto data kinds and the weights are attached for respective data kinds,the weights may be attached to respective data without classifying thedata by the data kinds.

When the step of S23 has been finished, as shown by the flowchart ofFIG. 4, weights are attached to all the data grasped at the referencerelationship grasping step at the second time (S22) (S24). That is, aweight of the increased data at a lowest order is successivelypropagated to higher order data constituting a source of reference.

Specifically, as shown by a flowchart of FIG. 10, first, the leak scorecalculating portion 117 acquires a set of all the data grasped at thereference relationship grasping step at the second time (S22) (S51) andacquires one piece of data which does have no successive data from theset of the data (S52).

Successively, it is determined whether the acquired data is the highestorder data (S53), when the acquired data is the highest order data, theoperation proceeds to S56 and adds the weight of the data to data at ahigher order constituting a source of reference of the data (S54) whenthe acquired data is not the highest order data. Further, after removingthe reference relationship of the data and the higher order data (S55),it is determined whether the set of the data is emptied (S56), when theset of the data is emptied, the processing is finished and when the setof the data is not emptied, the operation returns to S52. At S52, asdescribed above, one piece of data which has no successive data isacquired from the set of the data. In this case, at the previouslyexecuted processing of S55, as the reference relationship between theincreased data at the lowest order and the data of the data higher thanthat of the lowest order data is removed, the higher data becomes a datawhich has no successive data and therefore, the data is acquired. Thatis, by repeating the processing of S52 through S56, the weight of theincreased data is successively propagated to the higher order data.

For example, as shown by FIG. 11, when data C1 is acquired by theprocessing of S52, a weight “1” of data C1 is added to data B1 being thehigher order data of the source of reference of the data C1 and a weightof data B1 is set to “1”. Further, in the drawing, a numerical valueattached on a right upper side of respective data indicates the weight.Further, when data E2 is acquired in the processing of S52, a weight “2”of data E2 is added to data D0 constituting the higher order data of thesource of reference of data E2. Further, when data E3 is acquired in theprocessing of S52 again, a weight “2” of data E3 is added to data D0constituting the higher order data of the source of reference of dataE3. As a result, the higher order data D0 is added with the weight “2”of data E2 and the weight “2” of data E3 and therefore, the weight ofthe higher order data D0 becomes “4”. Further, when data D0 is acquiredin the processing of S52, the weight “4” of data D0 is added to data B0constituting data of the order higher than that of data D0 and theweight of data B0 is constituted by “4”. The weight of data A0 at thehighest order is added with the weights of data B0, B1 constitutinglower order data of a destination of reference and therefore, the weightbecomes “5”.

When S24 has been finished, as shown by the flowchart of FIG. 4, theleak score calculating portion 117 determines whether there are two ormore of data having the highest weight (S25). In such a case, that is,when there is only one piece of data having the highest weight, the datais made to constitute the highest leak score data with regard tooccurrence of memory leak (S26). Specifically, as shown by FIG. 11, whendata having the highest weight “5” is constituted only by data A0 at thehighest order, data A0 is made to constitute the highest leak scoredata. When there are two or more of data having the highest weight, dataat a lowest order in the data is made to constitute the highest leakscore data (S27). Specifically, as shown by FIG. 12, when there is onlydata B0 as data of a destination of reference of data A0 at the highestorder and all of the leak scores of data D0, data B0, data A0 are 4,data D0 at a lowest order in the data is made to constitute the highestleak score data.

When the highest leak score data has been calculated (S26, 27), a dataname of the highest leak score data and the leak score, a data name ofdata having a secondly higher leak score and the leak score, and a dataname of data having a thirdly higher leak score and the leak score areinformed to the program cause portion extracting portion 118 and thedisplay portion 119. The display portion 119 is further informed of allthe data grasped at the reference relationship grasping step of thesecond time (S22) and the reference relationship among the respectivedata (S28).

Next, operation of the program cause portion extracting portion 118 willbe explained in reference to a flowchart shown in FIG. 13.

When the program cause portion extracting portion 118 is informed of thename of the highest leak score data and the leak score from the leakscore calculating portion 117, the program cause portion extractingportion 118 starts operation and extracts a portion where data of thename of the highest leak score data is generated or substituted from theinspection object program 131 described in intermediate language storedto the program memory 130 (S61). The inspection object program 131described in the intermediate language is described with a row number ofa corresponding portion in the inspection object program 121 describedin Java language and therefore, after extracting the correspondingportion from the inspection object program 131 described in theintermediate language, the row number of the corresponding portion inthe inspection object program 121 is acquired from a row number tableset at a side of the corresponding portion (S62). Next, it is determinedwhether the row number of the substituted or generated portion isacquired with regard to all the data informed from the leak scorecalculating portion 117 and when the row number is acquired with regardto all the data, the operation proceeds to S64, and when the data whichdoes not acquire the row number remains, the operation returns to S61.At S64, the respective row number with regard to all the data isinformed to the display portion 119.

The display portion 119 displays information informed from the leakscore calculating portion 117 and the program cause portion extractingportion 118 on the display device 150 as described above.

Specifically, as shown by FIG. 14, the display device 150 displays aleak score ranking window 160, a reference relationship window 170, anda source code window 180.

The leak score ranking window 160 displays an order and a leak score161, a declaration class 162, a data name 163, a class to which databelongs 164, a program source name and a row number 165 described withthe corresponding data with regard to data having higher three orders ofleak scores informed from the leak score calculating portion 117.Further, although according to the example shown in FIG. 14, the leakscores are aligned in an order of the higher score degrees from above, adisplay in an order of lower leak scores or leak scores classified bynames can also be displayed.

The reference relationship window 170 displays a diagram showing all thedata grasped at the reference relationship grasping step of the secondtime and the reference relationship among the respective data which areinformed from the leak score detecting portion 117. According to thereference relationship diagram, an emphasized display 171 of datadesignated by the leak score ranking window 160 is executed. Further, aline 172 between nodes indicating the reference relationship isdisplayed by a boldness in accordance with the leak score. Further, withregard to data 173 displayed in the leak score ranking window 160, thedata 173 is displayed by a different color etc. in order todifferentiate from other data out of ranking. Further, although notillustrated here, the numerical value of the leak score calculated atthe leak score calculating portion 117 may be displayed at a side of anode indicating data.

The source code window 180 displays a corresponding row 181 in theinspection object program 121 described in Java language with regard todata designated by the leak score ranking window 160 and the rows at thevicinities of the row. Contents of the rows are extracted from theinspection object program 121 in Java language stored to the externalstoring device 120. The corresponding row 181 is displayed in anemphasized manner to differentiate from other rows. Here, there isdesignated the data name “vec” at a third order of the leak scoreranking in the leak score ranking window 160 and therefore, a row 181using the data name “vec” is displayed in an emphasized manner.

A system controller executes a processing of changing a program ofremoving a corresponding element data from an array class with regard tothe corresponding portion of the inspection object program 121 describedin, for example, Java language or disconnecting the referencerelationship of the corresponding element data by looking at theabove-described display content. Further, the data the referencerelationship of which is disconnected is collected from the data memory140 by the above-described garbage collection function.

As described above, according to the embodiment, data having a high leakscore is displayed along with the numerical value of the leak score, thereference relationship diagram of the data and the row of the inspectionobject program 121 described in Java language in which data having ahigh leak score is used are displayed and therefore, data constituting asource of generating memory leak is easily specified, further, time andlabor of searching for the corresponding portion from the program 121can be saved and labor required for investigating the source of −memoryleak can considerably be reduced.

Further, although according to the above-described embodiments, theobject of the invention is the program described in Java language, theinvention is not limited thereto but so far as the program is a programdescribed in a language capable of tracking a reference relationshipamong data with regard to a plurality of data stored in a memory withoutexplicitly executing allocation and release of a region in the memory, aprogram described in any language can be the object of the invention.

Having described a preferred embodiment of the invention with referenceto the accompanying drawings, it is to be understood that the inventionis not limited to the embodiments and that various changes andmodifications could be effected therein by one skilled in the artwithout departing from the sprit or scope of the invention as defined inthe appended claims.

1. A method of detecting a memory leak causing portion generated inexecuting a program described in a programming language capable oftracking a reference relationship among a plurality of data stored in amemory of a computer, said method comprising: a first relationshipgrasping step of grasping the reference relationship among a pluralityof data stored in the memory; a second relationship grasping step ofgrasping the reference relationship among the plurality of data storedin the memory after the first relationship grasping step; an increaseddata extracting step of extracting one or more pieces of increased datawhich are not present in the plurality of data whose referencerelationship is grasped by the first relationship grasping step from theplurality of data whose reference relationship is grasped at the secondrelationship grasping step; and a weighting step of attaching weights toeach one or more pieces of the increased data extracted at the increaseddata extracting step in accordance with data sizes of the respectiveincreased data, successively propagating the weights from lower orderdata of a destination of reference to higher order data of a source ofreference successively, when in a propagation process of the weights,one higher order data constitutes the reference relationship with aplurality of lower order data, adding the weights of the plurality oflower order data to constitute the weight of the one higher order dataand making the weights of the respective data leak scores indicating apossibility of causing the memory leak.
 2. The method of detecting amemory leak causing portion according to claim 1, wherein in theweighting step, one or more pieces of the increased data are classifiedfor respective data kinds and the weights in accordance with data sizesof respective data groups are attached to the classified data groups. 3.The method of detecting a memory leak causing portion according to claim1, further comprising: a highest leak score data extracting step ofextracting a lower order data as a data having a high possibility ofcausing a memory leak when a plurality of data having a highest weightare present in respective weights of the plurality of data constitutingthe reference relationship and the plurality of data having the highestweight constitutes a relationship between the higher order data and thelower data.
 4. The method of detecting a memory leak causing portion,according to claim 2 comprising: a highest leak score data extractingstep of extracting a lower order data as a data having a highpossibility of causing a memory leak when a plurality of data having ahighest weight are present in respective weights of the plurality ofdata constituting the reference relationship and the plurality of datahaving the highest weight constitutes a relationship between the higherorder data and the lower order data.
 5. The method of detecting a memoryleak causing portion according to claim 1, further comprising: a memoryleak detecting step of investigating on an amount of using the memory bya plurality of times and determining whether the memory leak isgenerated from a result of the investigation of the plurality of times;wherein the second relationship grasping step is executed in parallelwith when it is determined that the memory leak is generated in thememory leak detecting step or thereafter.
 6. The method of detecting amemory leak causing portion according to claim 5, wherein in the memorydetecting step, it is determined that the memory leak is generated whenthe memory using amount has been increased at a investigation after acertain investigation among a plurality of investigations in a amountequal to or larger than a previously determined increased amountrelative to the memory using amount in the certain investigation.
 7. Themethod of detecting a memory leak causing portion according to claim 1,further comprising: a program cause portion extracting step ofextracting a portion described with a data having a high possibility ofcausing the memory leak from the program.
 8. The method of detecting amemory leak causing portion according to claim 5, further comprising: aprogram cause portion extracting step of extracting a portion describedwith a data having a high possibility of causing the memory leak fromthe program.
 9. The method of detecting a memory leak causing portionaccording to claim 7; wherein the program described in the programminglanguage is a program executed by being converted into an intermediatelanguage; and wherein in the program cause portion extracting step, aportion described with the data having a high possibility of causing thememory leak is found from the program converted into the intermediatelanguage and a portion corresponding to the portion thus found isextracted from the program described in the programming language. 10.The method of detecting a memory leak causing portion according to claim8; wherein the program described in the programming language is aprogram executed by being converted into an intermediate language; andwherein in the program cause portion extracting step, a portiondescribed with a data having a high possibility of causing the memoryleak is found from the program converted into the intermediate languageand a portion corresponding to the portion thus found is extracted fromthe program described in the programming language.
 11. The method ofdetecting a memory leak causing portion according to claim 1, furthercomprising: a displaying step of displaying at least a result of theweighting step.
 12. A program for detecting a memory leak causingportion generated in executing a program described in a programminglanguage capable of tracking a reference relationship among a pluralityof data stored in a memory of a computer, the program causing thecomputer to execute: a first relationship grasping step of grasping thereference relationship among the plurality of data stored in the memory;a second relationship grasping step of grasping the referencerelationship among the plurality of data stored to the memory after thefirst relationship grasping step; an increased data extracting step ofextracting one or more pieces of increased data which are not present inthe plurality of data whose reference relationship is grasped by thefirst relationship grasping step from the plurality of data thereference relationship of which is grasped at the second relationshipgrasping step; and a weighting step of attaching weights to each of oneor more pieces of the increased data extracted at the increased dataextracting step in accordance with data sizes of the respectiveincreased data, successively propagating the weights from lower orderdata of a destination of reference to higher order data of a source ofreference successively, when in a propagation step of the weights, onehigher order data constitutes the reference relationship with aplurality of lower order data, adding the weights of the plurality oflower order data to constitute the weight of the one higher order dataand making the weights of the respective data leak scores indicating apossibility of causing the memory leak.
 13. The program for detecting amemory leak causing portion according to claim 12, wherein in theweighting step, one or more pieces of the increased data are classifiedfor respective data kinds and weights in accordance with data sizes ofrespective data groups are attached to the classified data groups. 14.The program for detecting a memory leak causing portion according toclaim 12, the program causing the computer to execute: a highest leakscore extracting step of extracting a lower order data as a data havinga high possibility of causing a memory leak when there are a pluralityof data having a highest weight in respective weights of the pluralityof data constituting the reference relationship and the plurality ofdata having the highest weight constitutes a relationship between thehigher order data and the lower order data.
 15. The program fordetecting a memory leak causing portion according to claim 13, theprogram causing the computer to execute: a highest leak score dataextracting step of extracting a lower order data as a data having a highpossibility of causing a memory leak when a plurality of data having ahighest weight are present in respective weights of the plurality ofdata constituting the reference relationship and a plurality of datahaving the highest weight constitutes a relationship between the higherorder data and the lower data.
 16. The program for detecting a memoryleak causing portion according to claim 12, the program causing thecomputer to execute: a memory leak detecting step of investigating on anamount of using the memory by a plurality of times and determiningwhether the memory leak is generated from a result of the investigationof the plurality of times; wherein the second relationship grasping stepis executed in parallel with the time when it is determined that thememory leak is generated in the memory leak detecting step therewith orthereafter.
 17. The program for detecting a memory leak causing portionaccording to claim 16, wherein in the memory leak detecting step, in theinvestigation of the plurality of times, it is determined that thememory leak is generated when the memory using amount has been increasedin an investigation after a certain investigation among a plurality ofinvestigations in a amount equal to or larger than a previouslydetermined increased amount, relative to the memory using amount in thecertain investigation,
 18. The program for detecting a memory leakcausing portion according to claim 12, the program causing the computerto execute: a program cause portion extracting step of extracting aportion described with a data having the high leak score from theprogram.
 19. The program for detecting a memory leak causing portionaccording to claim 16, the program causing the computer to execute: aprogram cause portion extracting step of extracting a portion describedwith a data having the high leak score from the program.
 20. The programfor detecting a leak-causing portion memory leaks according to claim 18,wherein the program described in the programming language is a programexecuted by being converted into an intermediate language; and whereinin the program cause portion extracting step, a portion described withthe data having the high leak score is found from the program convertedinto the intermediate language and a portion corresponding to theportion thus found is extracted from the program described in theprogramming language.
 21. The program for detecting a memory leakcausing portion according to claim 19, wherein the program described inthe programming language is a program executed by being converted intoan intermediate language; and wherein in the program-caused extractingportion extracting step, a portion described with the data having thehigh leak score is found from the program converted into theintermediate language and a portion corresponding to the portion thusfound is extracted from the program described in the programminglanguage.
 22. The program for detecting a memory leak causing portionaccording to claim 19, the program causing the computer to execute: adisplaying step of displaying at least a result of the weighting step.23. The program for detecting a memory leak causing portion according toclaim 22, wherein in the displaying step, the plurality of data graspedat the second relationship grasping step is displayed in a manner thatthe reference relationship is seen and the leak scores of the pluralityof data are respectively displayed.
 24. The program for detecting amemory leak causing portion according to claim 18, the program causingthe computer to execute: a displaying step of displaying a data name ofthe data having the highest leak score, a declaration of a data kind ofthe data, a portion of describing the data in the program described inthe programming language.
 25. The program for detecting memory leakcausing portion according to claim 24, wherein the program language isJava language; and wherein in the displaying step, the data kind towhich the data belongs is displayed in relation to the data name of thedata having the highest leak score.
 26. The program of detecting amemory leak causing portion according to claim 19 wherein the program isa program provided by a Web service.